import java.util.ArrayList;
public class Solution {
    public int minNumberInRotateArray(int [] array) {
        int length = array.length;
        if (length == 1) {
            return array[0];
        }
        
        int minm = array[0] > array[length - 1] ? array[length - 1] : array[0];
        int left = 0;
        int right = length - 1;
        int mid = 0;
        while (left < right) {
            mid = (left + right) / 2;
            if (array[mid] > array[right]) {
                left = mid + 1;
            }
            else if (array[mid] == array[right]) {
                right--;
            }
            else {
                right = mid;
            }
        }
        return array[left];
    }
}
